﻿@using Coevery.OptionSet.Settings
@model OptionSetFieldSettings
<section class="control-group data-row">
    <label class="control-label">@T("Options")</label>
    <div class="controls errortips">
        @Html.TextAreaFor(m => m.Options, new {@class = "span12", rows = "25", cols = "80", required=""})
        <p class="help-block">@T("Enter an option per line.")</p>
    </div>
</section>
<section class="control-group data-row">
    <label class="control-label">@T("List mode")</label>
    <div class="controls">
        <select id="@Html.FieldIdFor(m => m.ListMode)" name="@Html.FieldNameFor(m => m.ListMode)">
            @Html.SelectOption(ListMode.Dropdown, Model.ListMode == ListMode.Dropdown, T("Dropdown list").ToString())
            @Html.SelectOption(ListMode.Radiobutton, Model.ListMode == ListMode.Radiobutton, T("Radio button list").ToString())
            @*@Html.SelectOption(ListMode.Listbox, Model.ListMode == ListMode.Listbox, T("Listbox").ToString())*@
            @Html.SelectOption(ListMode.Checkbox, Model.ListMode == ListMode.Checkbox, T("Checkbox").ToString())
        </select>
    </div>
</section>
@Html.HiddenFor(model => model.OptionSetId)

@using (Script.Foot()) {
    <script type="text/javascript">
        //<![CDATA[
        function insertAtCursor(myField, myValue) {
            //IE support
            if (document.selection) {
                myField.focus();
                sel = document.selection.createRange();
                sel.text = myValue;
            }

                //MOZILLA/NETSCAPE support
            else if (myField.selectionStart || myField.selectionStart == '0') {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                var restoreTop = myField.scrollTop;

                myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);

                myField.selectionStart = startPos + myValue.length;
                myField.selectionEnd = startPos + myValue.length;

                if (restoreTop > 0) {
                    myField.scrollTop = restoreTop;
                }
            }
            else {
                myField.value += myValue;
            }
        }

        function interceptTabs(evt, control) {
            var key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
            if (key == 9) {
                insertAtCursor(control, '\t');
                return false;
            }
            else {
                return key;
            }
        }
        //]]>
    </script>
}